package com.link.base.task;

import com.link.base.base.sms.service.TemplateService;
import com.link.base.core.basic.config.xxljob.BaseLinkJobHandler;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 定时发送延迟模板消息
 *
 * @author guguishan
 * @date   2019/9/4 14:28
 */
@JobHandler(value = "TaskSceneMessage")
@Component
public class TaskSceneMessage extends BaseLinkJobHandler {

    @Resource
    private TemplateService templateService;

    @Override
    public ReturnT<String> execute(String strings) throws Exception {
        try {
            XxlJobLogger.log("XXL-JOB, scene template message ...");
            templateService.sendScheduledSceneMessage();
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            XxlJobLogger.log(e.getMessage());
            return ReturnT.FAIL;
        }
    }
}
